<?php

namespace Dddxiu\rules;

use Dddxiu\Layer;

/**
 * 手机
 */
class phoneCN implements Rule
{
    // flag
    const F = 'phoneCN';


    /**
     * @param array $input
     * @param string $field
     * @param Layer $layer
     * @param array $args
     * @return \Closure|bool
     * @throws \Exception
     */
    public static function valid($input, $field, $layer, $args)
    {
        $pass = (preg_match("/^1[3456789]\d{9}$/", $input[$field]) === 1);
        if ($pass) {
            return $layer::next(Layer::FIELD_TYPE_STR);
        }
        return false;
    }
}